<template>
	<view>
		<!-- 头部导航栏 -->
		<activity-navbar></activity-navbar>
		<!-- 选择框 -->
		<activity-dropdown @chooseOrder="chooseOrder"></activity-dropdown>
		<!-- 中间内容 -->
		<scroll-view scroll-y :style="{height:listHeight+'px'}">
			<activityList :data="dataList"></activityList>
		</scroll-view>
	</view>
</template>

<script>
	import activityNavbar from "../../components/activity/activity-navbar.vue";
	import activityDropdown from "../../components/activity/activity-dropdown.vue";
	import activityList from "../../components/activity/activity-list.vue";
	export default {
		components: {
			activityNavbar,
			activityDropdown,
			activityList
		},
		data() {
			return {
				tabIndex: 0,
				listHeight: this.swiperHeight-85,
				tabBars: [{
						name: "热点社团",
						id: "0"
					},
					{
						name: "社团宣传",
						id: "1"
					}
				],
				dataList:[],
				page:1,
				rows:20,
				order:0,
			}
		},
		onShow(){
			this.loadActivity()
		},
		methods: {
			// 监听子组件的tab点击事件
			tabtap(index) {
				this.tabIndex = index;
			},
			// tab滑动事件
			tabChange(e) {
				this.tabIndex = e.detail.current
			},
			loadActivity(){
				uni.request({
					url: this.url.movement.getAllLegalData, 
					method:'GET',
					header: {},
					success: (res) => {
						var data = res.data.allLegalData;
						for(var i=0;i<data.length;i++){
							var dayTime = new Date(data[i].endTime)
							data[i].endDay = dayTime.getMonth() + 1 +"-"+dayTime.getDate()
							data[i].endTime = dayTime.getHours()+":"+dayTime.getMinutes()
						}
						this.dataList=data
						console.log(this.dataList)
					},
					fail:(res)=>{
						console.log(res)
					}
				});
			},
			chooseOrder(index){
				console.log(index)
				this.order = index
				uni.request({
					url: this.url.movement.orderList+"/"+this.page+"/"+this.rows+"/"+this.order, 
					method:'GET',
					header: {},
					success: (res) => {
						var data = res.data.movementList;
						console.log(data);
						this.dataList = data;
					},
					fail:(res)=>{
						console.log(res)
					}
				});
			}
		}
	}
</script>

<style>
	
</style>
